import { EDITOR } from "cc/env";

/*
 * @features: 功能
 * @description: 说明
 * @Date: 2021-10-07 14:22:54
 * @Author: judu233(769471424@qq.com)
 * @LastEditTime: 2021-10-27 22:23:01
 * @LastEditors: judu233
 */
export const setI18nCom = (com: { prototype: { onDestroy, onLoad } }) => {
    if (!EDITOR && GM) {
        let onLoad = com.prototype.onLoad;
        com.prototype.onLoad = function () {
            GM?.i18n?.setLangByCom(this);
            onLoad?.call(this,arguments);
        }
        let destory = com.prototype.onDestroy;
        com.prototype.onDestroy = function () {
            GM?.i18n?.releasrLanguCom(this);
            destory?.call(this,arguments);
        }
    }
}